//
//  HomeViewController.m
//  Dormitory2404
//
//  Created by gleeman.G on 2017/12/20.
//  Copyright © 2017年 Hainan Suyun network technology co. LTD. All rights reserved.
//

#import "HomeViewController.h"
#import "NewBillsViewController.h"
#import "HistoryListVC.h"

@interface HomeViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self tableViewSetting];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewWillAppear:(BOOL)animated {
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    
    [super viewWillDisappear:animated];
}

- (void)tableViewSetting{
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
    self.tableView.tableFooterView = [[UIView alloc]init];
    
}

- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([UITableViewCell class])];
    cell = [cell initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([UITableViewCell class])];
    cell.textLabel.text = [self titleForCell:indexPath];
    cell.detailTextLabel.text = [self subtitleForIndexPath:indexPath];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:12.f];
    cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.row == 4) {
        cell.detailTextLabel.textColor = [UIColor redColor];
    }else{
        cell.detailTextLabel.textColor = [UIColor lightGrayColor];
    }
    return cell;
}

- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 5;
}


- (NSString *)titleForCell:(NSIndexPath *)index{
    NSArray * array = @[@"周浪",@"陈椰聪",@"许坤水",@"梁俊杰",@"☺☺☺"];
    return array[index.row];
}

- (NSString *)subtitleForIndexPath:(NSIndexPath *)index{
    NSArray * array = @[@"寝室长",@"沟民",@"沟长",@"拆二代",@"不详"];
    return array[index.row];
}

- (IBAction)payButton:(id)sender {
    NewBillsViewController *vc = [[NewBillsViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)historyButtonClick:(id)sender {
    HistoryListVC *vc = [[HistoryListVC alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}



@end
